/*
 * @Author: geyulan 18500325526@163.com
 * @Date: 2020-04-26 10:56:12
 * @LastEditors: geyulan 18500325526@163.com
 * @LastEditTime: 2023-12-12 18:04:12
 * @FilePath: /coupon-laxin/src/api/index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import fetch from './ajax'
// import Md5 from 'js-md5'

export const DEBUG = true // 是否开发模式
const CITY_DEV = 'https://precrm.cpgroup.cn' // 测试地址
const CITY_URL = 'https://cpcrm.cpgroup.cn' // 正式地址
const CITYURLS = DEBUG ? CITY_DEV : CITY_URL

// const CHANGE_URL = 'http://zdcrm.c8fb1f72e2deb4c7292ce51eaf69e2572.cn-shenzhen.alicontainer.com/gateway'
const CHANGE_URL = `${CITYURLS}/gateway`

// let times = Date.parse(new Date()) / 1e3
// let md5 = Md5(times + '74913ea145667f0f')
class XHR {
  // 获取有效积分总量
  getAvailablePoints (json) {
    return fetch({
      url: `${CHANGE_URL}/api/web-openapi/v1/memberPoint/availablePoints`,
      body: json,
      type: 'GET'
    })
  }
  // 获取积分明细
  queryPointsRecord (json) {
    return fetch({
      url: `${CHANGE_URL}/api/web-openapi/v1/memberPoint/queryPointsRecord`,
      body: json,
      type: 'POST'
    })
  }
  // 页面点击统计
  getClick (json) {
    return fetch({
      url: `${CHANGE_URL}/api/web-openapi/v1/click`,
      body: json,
      type: 'GET'
    })
  }
  // h5获取目标跳转链接
  getTargetUrl (json) {
    return fetch({
      url: `${CHANGE_URL}/v1/plat/getTargetUrl`,
      body: json,
      type: 'POST'
    })
  }
  // 小程序跳转链接申请
  getApplyLink (json) {
    return fetch({
      url: `${CHANGE_URL}/api/web-openapi/v1/h5/applyLink`,
      body: json,
      type: 'POST'
    })
  }
}
export default new XHR()
